package com.bing.service;

import com.bing.utils.idgenertor.IdGen;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.bing.entity.LoanProducts.Channelnfo;
import com.bing.mapper.ChannelnfoMapper;

@Service
public class ChannelnfoService {

    private Integer PAGE_SIZE = 5;

    @Autowired
    private ChannelnfoMapper channelnfoMapper;

    public int insert(Channelnfo channelnfo){
        return channelnfoMapper.insert(channelnfo);
    }


    public int insertSelective(Channelnfo channelnfo){
        String id = channelnfoMapper.getMaxId();
        if (StringUtils.isEmpty(id)){
            channelnfo.setChannlId("100001");
        } else {
            channelnfo.setChannlId(String.valueOf(Integer.valueOf(id)+1));
        }
        return channelnfoMapper.insertSelective(channelnfo);
    }


    public int insertList(List<Channelnfo> channelnfos){
        return channelnfoMapper.insertList(channelnfos);
    }


    public int updateByPrimaryKeySelective(Channelnfo channelnfo){
        return channelnfoMapper.updateByPrimaryKeySelective(channelnfo);
    }


    public Channelnfo getChannelDetail(String channelId) {
        return channelnfoMapper.getChannelDetail(channelId);
    }


    public PageInfo<Channelnfo> getChannelList(Integer pageNum) {
        PageHelper.startPage(pageNum, PAGE_SIZE);
        List<Channelnfo> list =  channelnfoMapper.getChannelList();
        return new PageInfo<Channelnfo>(list);

    }
}
